using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class JSONDB : MonoBehaviour{
	
	public string _rulesInternal;
	
	public Dictionary<string,Dictionary<string,string>> rules
	{
		get
		{
			Dictionary<string,Dictionary<string,string>> r = new Dictionary<string, Dictionary<string, string>>();
			
			Dictionary<string,object> d = MiniJSON.Json.Deserialize(_rulesInternal) as Dictionary<string,object>;
			
			foreach(var d2 in d)
			{
				r.Add(d2.Key, new Dictionary<string, string>());
				Dictionary<string, object> d3 = MiniJSON.Json.Deserialize(d2.Value as string) as Dictionary<string, object>;
				
				foreach(var d4 in d3)
				{
					r[d2.Key].Add(d4.Key, d4.Value as string);
				}
			}
			
			return r;
		}
		set
		{
			Dictionary<string, string> stage1 = new Dictionary<string, string>();
			
			foreach(var d in value)
			{
				stage1.Add(d.Key, MiniJSON.Json.Serialize(d.Value));
			}
			
			_rulesInternal = MiniJSON.Json.Serialize(stage1);
		}
	}
}
